package com.edu.servlet;

import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.edu.bean.Comment;
import com.edu.service.CommentService;
import com.edu.service.impl.CommentServiceImpl; 
@WebServlet("/updatecomment.do")
public class UpdateCommentServlet extends HttpServlet{
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		CommentService cs = new CommentServiceImpl();
		String id = req.getParameter("commentid");
		String uid = req.getParameter("userid");
		String cid = req.getParameter("carid");
		String name = req.getParameter("commentidStrign");
		String updatedat = req.getParameter("commentidTime");
		int commentid = Integer.parseInt(id);
		int userid = Integer.parseInt(uid);
		int carid = Integer.parseInt(cid);
		DateFormat dft = new SimpleDateFormat("yyyy-MM-dd");
		Date update=null;
		try {
			update =dft.parse(updatedat);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Comment comment = new Comment(commentid,userid,carid,name,update);
		cs.updateComment(comment);
	}
}
